<?php
require_once('tpl/head.php');
include_once('./system/dbConn.php');
connect();
//$tid=$_GET["tid"];
$page=1;
$flag=1;
//分页
        if (isset($_GET["page"])) {
            $page=$_GET["page"];
        }
//查找
if (isset($_GET["key"])) {
    $key=$_GET["key"];
}


         
$sql0="select * from videos where videoname like '%$key%'";
$result0=mysql_query($sql0);
$num0=mysql_num_rows($result0);
$row0=mysql_fetch_assoc($result0);
//$typename=$row0["typename"];
if ($num0==0) {
    $flag=0;
}
$totalrows=$num0;
$pagerows=5;
$totalpages=ceil($totalrows/$pagerows);
$start=($page-1)*$pagerows;
$sql1=$sql0." limit $start,$pagerows";
//echo $sql1;
$result1=mysql_query($sql1);
//var_dump($result1);
//$row1=mysql_fetch_assoc($result1);
//var_dump($num0);

?>


<div class="container">

    <div class="row row-offcanvas row-offcanvas-right">

        <div class="col-xs-12 col-sm-9">
        

            <div class="row">


                <div class="col-xs-12 col-lg-12 mlist">
                    <h2>搜索结果</h2>
                        <?php if ($flag==0) {
                            echo "未找到符合条件的记录";
                        } ?>
                    <ul class="list-inline row text-center">
                    <?php while ($row=mysql_fetch_assoc($result1)) {   
                        //var_dump($row);
                         ?>
                        <li class="col-xs-6 col-lg-3">
                            <img src="./posters/<?php echo $row["pic"]; ?>" class="responsive img-thumbnail"/>

                            <p><a href="show.php?vid=<?php echo $row["vid"]; ?>"><?php echo $row["videoname"]; ?></a>
                            </p>
                        </li>
                    <?php } ?>

                    </ul>
                    <nav class="text-center">
                        <ul class="pagination">
                            <li>
                                <a href="#" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </li>
                            <li><a href="#?page=1">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li><a href="#">4</a></li>
                            <li><a href="#">5</a></li>
                            <li>
                                <a href="#" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                        </ul>
                    </nav>


                </div>
                <!--/.col-xs-6.col-lg-4-->

            </div>
            <!--/row-->
        </div>
        <!--/.col-xs-12.col-sm-9-->

        
    </div>
    <!--/row-->

    

</div>
<!--/.container-->
<?php
require_once('tpl/foot.php');
?>
